import { Widget, _decorator, Node, Label, Vec3, tween, isValid, math, Component } from 'cc';
// import { UIBase } from '../scriptBase/UIBase';
// import { UI } from '../enum/UI';
import { GameMgr } from '../manager/GameMgr';
import UI from 'db://assets/Script/Manager/UI';
import { UIPause } from './UIPause';

const { ccclass, property, requireComponent } = _decorator;

@ccclass('UI/UIGame')
@requireComponent(Widget)
export class UIGame extends Component {
    public static Instance: UIGame;

    @property(Label)
    public lbLevel: Label | null = null;
    @property(Node)
    public BtnSetting: Node | null = null;

    ShowOn() {
        this.node.active = true;
        this.lbLevel.string = `第${GameMgr.CurLevel + 1}关`

    }
    ShowOff() {
        this.node.destroy();
    }

    onLoad(): void {
        UIGame.Instance = this;

        this.AddListener();
    }

    AddListener() {
        this.BtnSetting.on(Node.EventType.TOUCH_END, this.On_BtnSetting, this);
    }

    On_BtnSetting() {
        // this.open(UI.Pause)
        UI.Instance.CreatePanel_sub(`ui`, `UIPause`, UIPause);
    }

    // onOpen(data?: any): void {
    //     this.lbLevel.string = `第${GameMgr.CurLevel + 1}关`
    // }

    // onBtnSettingClick(): void {
    //     this.open(UI.Pause)
    // }
}